class contactModel{
  constructor(){
    this.db = require('../../config/db')
  }
  //获取所有招聘信息
  contactInfo(){
    let sql = 'select * from contact ORDER BY pudate DESC'
    return this.db.query(sql)
  }
  //ID获取用户信息
  contactID(id){
    let sql = 'select * from contact where id = ?'
    return this.db.query(sql,id)
  }

  //获取招聘分页信息
  contactPage(pagenum,per_page){
    let sql = 'select * from contact order by pudate DESC limit ?,?'
    return this.db.query(sql,[pagenum,per_page])
  }
  //增加招聘信息
  contactAdd(num,content1,content2,email,title){
    let sql = "insert into contact (num,content1,content2,email,title) values (?,?,?,?,?)"
    return this.db.query(sql,[num,content1,content2,email,title])
  }

  //修改招聘信息
  contactUpdate(num,content1,content2,email,title,id){
    let sql = "update contact set num = ?, content1 = ?, content2 = ?,email = ?, title = ? where id = ?"
    return this.db.query(sql,[num,content1,content2,email,title,id])
  }

  //删除招聘信息
  contactDelete(id){
    let sql = 'delete from contact where id = ?'
    return this.db.query(sql,[id])
  }
}
module.exports = new contactModel()